home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1998 #3
/
Amiga Plus CD - 1998 - No. 3.iso
/
pd
/
spiele
/
progammon2.3
/
dicetests
/
dice.docs
next >
Wrap
Text File
|
1997-12-08
|
4KB
|
81 lines
Testing the Dice:
Have you ever noticed while playing ProGammon that sometimes the computer
rolls exactly what it needs? Have you ever thought that the dice are not
truly random or that the program is just plain cheating! To be honest,
I was curious as to whether the dice are random so I wrote a small program
to test them. The dice tests convinced me so now let's see if I can
convince you.
First off, the program uses the UNIX compatible SAS/C random number
generating function called drand48(). It also uses the function
srand48( seed ) to set the random number seed. drand48() produces random
numbers between the values of 0.0 and 1.0 but not including 1.0. The
following is how I convert this value into a dice value:
dice[ 1 ] = (int)( ceil( drand48() * 6.0 ) );
dice[ 2 ] = (int)( ceil( drand48() * 6.0 ) );
These 2 simple lines of C code are what controls the dice. The RollDice()
subroutine has no idea whether it is being called to roll the dice for you
or for the Amiga. It does not check to see who is on the bar or what
points are blocked or whether it's the start of the game or the end. All
it does is just roll the dice. The Amiga is not cheating just because it
rolls a 6 to start the game or rolls doubles to end the game. It has
gotten lucky and if you play enough games I'm sure that you will get lucky
too. If you don't think the dice are random then I guess you should send
your complaints to the people who wrote the drand48() function. Before
you do though, I think you should check out the output from my DiceTest
program. This proved to me that the drand48() function produces random
numbers that are just as random as any set of dice.
DiceTest:
Included in this drawer are the results of a dice testing program that I
wrote. I ran the program 5 times and the results are in DiceTest1 to
DiceTest5. The source code for this program is available if you like.
The program rolls a set of dice 108 000 times to see if every combination
is equally likely. You should see each combination 1/36th of the time so
you can expect to see about 3 000 entries for each. The program produces
a 6 x 6 table to show you the results.
Have you ever noticed the exact same thing being rolled twice in a row.
Also, sometimes you will roll a 5 2 and then a 2 5. With normal dice,
either one of these events will occur 1/36th of the time. This test
checks for these 2 events which should occur about 3 000 times.
The next test checks for the same thing being rolled 3 times in a row.
If the Amiga rolled double sixes 3 times in a row you would be more than
just a little suspicious but this does occur with normal dice 1/1296th of
the time. In this test we should see this happen about 83 times.
Checking for the frequency of doubles is the next test. A normal pair of
dice will come up with doubles approximately 1/6th of the time. After
108 000 rolls you would expect there to be about 18 000 doubles.
Finally, the total amount rolled is computed. Each roll in backgammon
averages 8.167 when taking doubles into account so the total should be
somewhere around 882 000 if the dice are legal.
I hope that seeing the results of this test will convince you that the
dice used in ProGammon are 100% random. Of course, there are going to be
some people who are willing to agree that these dice are random but the
ones in the game are not. For this reason, ProGammon also compiles
statistics while you play. Both players average dice roll should start to
approach the theoretical value of 8.167 within about 25 games. Hopefully,
this will help prove to you that the Amiga does not cheat and is merely
playing a damn good game of backgammon! Go ahead, see for yourself.
Every roll of the dice are saved in the gammon.prefs file after you
complete at least one game and select Quit in the menus or close the game
screen. During the game you can select Stats in the menus to see the
averages for the games that you are presently playing. By clicking on the
right portion of the statistics screen you can also examine the stats saved
in the gammon.prefs file.
After you play a large number of games you should be convinced that the
dice are 100% legal. Good luck!